package cn.kmsoft.spatialboot.service.impl;

import cn.kmsoft.spatialboot.config.dbswitch.DynamicSwitch;
import cn.kmsoft.spatialboot.common.object.Region;
import cn.kmsoft.spatialboot.dao.RegionQueryDao;
import cn.kmsoft.spatialboot.service.RegionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author linglei
 * @date 2018/1/10.
 */
@Service
@Transactional(readOnly = true, rollbackFor = Exception.class)
public class RegionServiceImpl implements RegionService {

    private final RegionQueryDao regionQueryDao;

    @Autowired
    public RegionServiceImpl(RegionQueryDao regionQueryDao) {
        this.regionQueryDao = regionQueryDao;
    }

    @DynamicSwitch
    @Override
    public List<Region> queryRegion(String instanceName, String code) {
        return regionQueryDao.queryRegion(code);
    }
}
